home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / misc / math / MathFX_src.lha / strpos.c < prev    next >
C/C++ Source or Header  |  1995-12-20  |  487b  |  20 lines

  1. /* Searches string str for first occurence of character chr.  If found */
  2. /* the position of the character in the string is returned (the first  */
  3. /* character has position 0).  If the character is not found a -1 is   */
  4. /* returned. */
  5.  
  6. #include "mathfx.h"
  7. #include <stdio.h>     /* Needed to define NULL */
  8. #include <string.h>
  9.  
  10. int strpos(str,chr)
  11. char *str,chr;
  12. {
  13.     char *temp;
  14.  
  15.     if ( (temp = strchr(str,chr)) != NULL)
  16.         return(temp - str);
  17.     else
  18.         return(-1);
  19. }
  20.